import { apiHttp } from '../../apiHttp';
import Api from '../../../api/system/sysRoleController.api';
import AuthApi from '../../../api/system/sysMenuController.api';
//import { JsonResult, SysRoleInfoVO, PageResult, SysRole, MenuDto} from '../../../api/Interface';
import { JsonResult, MenuDto, SysGrantMenuTree, PageResult, SysRole } from '../../../api/Interface';
import { sysRoleSearchDto } from '../systemInterface';
export default {
    // 获取角色信息》》
    sysRoleById: async (roleIdInfo: {roleId: string}): Promise<SysRole> => {
        const res: JsonResult = await apiHttp(Api.sysRoleById, roleIdInfo);
        return res.data;
    },
     // 删除角色
     sysRoleDelete: async (roleIdInfo: {roleId: string}): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(Api.sysRoleDelete, roleIdInfo);
        return res;
    },
    // 新建角色
    sysRoleInsert: async (roleInfo: SysRole): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(Api.sysRoleInsert, roleInfo);
        return res;
    },
    // //获取角色列表  ===>参数类型需要修改
    sysRolePage: async (listParams: sysRoleSearchDto): Promise<PageResult> => { //sysRoleSearchDto
        const res: JsonResult = await apiHttp(Api.sysRolePage, listParams);
        return res.data;
    },
    //获取全部角色列表
    sysRoleAll: async (): Promise<SysRole[]> => { //List
        const res: JsonResult = await apiHttp(Api.sysRoleAll);
        return res.data;
    },
    // 角色授权初始数据
    getGrantMenuTree: async (roleId: string): Promise<SysGrantMenuTree[]> => {
        const res: JsonResult = await apiHttp(AuthApi.getGrantMenuTree, {roleId});
        return res.data;
    },
    // 角色授权
    grant: async (menuDto: MenuDto): Promise<JsonResult> => {
        const res: JsonResult = await apiHttp(Api.grant, menuDto);
        return res;
    },
    //修改角色
    sysRoleUpdate: async (roleInfo: SysRole): Promise<JsonResult> => { //roleRecord
        const res: JsonResult = await apiHttp(Api.sysRoleUpdate, roleInfo);
        return res;
    },
};